/*
 Copyright (C) 2010 QDSS.org
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.qdss.persist.dialect.function;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import org.qdss.persist.dialect.FieldType;
import org.qdss.persist.dialect.Type;

/**
 * <tt>$GETDATE</tt>
 * 
 * @author <a href="mailto:zhaofang123@gmail.com">Zhao Fangfang</a>
 * @since 0.2, 2010-9-2
 * @version $Id: GetDateFunction.java 119 2011-05-15 16:56:18Z zhaofang123@gmail.com $
 */
public class GetDateFunction implements SqlFunction {

	public String getToken() {
		return "getdate";
	}
	
	public Type getReturnType() {
		return FieldType.DATE;
	}

	public boolean hasArguments() {
		return false;
	}

	public String render(Object[] arguments) {
		return new SimpleDateFormat("yyyy-MM-dd").format(
				Calendar.getInstance().getTime());
	}
}
